Back to course home
0% completed
Vote For New Content
Minimum Window Substring (hard)
Problem Statement
Given a string s and t of length m and n respectively, find the smallest substring in a given string 's' that contains all the characters (including duplicate) of another string 't'. The order of characters in 't' doesn't matter, but the substring in 's' must include all characters of 't', possibly with additional characters.
If no such substring exists, return an empty string.
Examples
Example 1:
- Input: s = "xyyzyzyx", t = "xyz"
- Expected Output: "zyx"
- Justification: "zyx" is the shortest substring of 's' that contains 'x', 'y', and 'z'.
Example 2:
- Input: s = "abracadabra", t = "aa"
- Expected Output: "ada"
- Justification: "ada" at the end of 's' is the shortest substring containing all 'a's in 't'.
Example 3:
- Input: s = "welcomeback", t = "ole"
- Expected Output: "elco"
- Justification: "elco" includes 'o', 'l', and 'e', fulfilling the requirements with the minimum length.
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Alien Dictionary
Solution: Minimum Window Substring
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself